home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / iv26_w30.zip / INTERVIE / PAINTER.H < prev    next >
C/C++ Source or Header  |  1992-02-25  |  6KB  |  174 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * Graphics interface
  25.  */
  26.  
  27. #ifndef painter_h
  28. #define painter_h
  29.  
  30. #include <InterViews/defs.h>
  31. #include <InterViews/resource.h>
  32.  
  33. class Canvas;
  34. class Color;
  35. class PainterRep;
  36. class Pattern;
  37. class Brush;
  38. class Dash;
  39. class Font;
  40. class Transformer;
  41. class Bitmap;
  42. class Raster;
  43.  
  44. class Painter : public Resource {
  45. public:
  46.     Painter();
  47.     Painter(Painter*);
  48.     ~Painter();
  49.  
  50.     void FillBg(boolean);
  51.     boolean BgFilled();
  52.     void SetColors(Color* f, Color* b);
  53.     Color* GetFgColor();
  54.     Color* GetBgColor();
  55.     void SetPattern(Pattern*);
  56.     Pattern* GetPattern();
  57.     void SetBrush(Brush*);
  58.     Brush* GetBrush();
  59.     void SetFont(Font*);
  60.     Font* GetFont();
  61.     void SetStyle(int);
  62.     int GetStyle();
  63.     void SetTransformer(Transformer*);
  64.     Transformer* GetTransformer();
  65.     void MoveTo(int x, int y);
  66.     void GetPosition(int& x, int& y);
  67.     void SetOrigin(int x0, int y0);
  68.     void GetOrigin(int& x0, int& y0);
  69.  
  70.     void Translate(float dx, float dy);
  71.     void Scale(float x, float y);
  72.     void Rotate(float angle);
  73.  
  74.     void Clip(Canvas*, Coord left, Coord bottom, Coord right, Coord top);
  75.     void NoClip();
  76.     void SetOverwrite(boolean);
  77.     void SetPlaneMask(int);
  78.  
  79.     void Text(Canvas*, const char*);
  80.     void Text(Canvas*, const char*, int);
  81.     void Text(Canvas*, const char*, Coord, Coord);
  82.     void Text(Canvas*, const char*, int, Coord, Coord);
  83.     void Stencil(Canvas*, Coord x, Coord y, Bitmap* image, Bitmap* mask = nil);
  84.     void RasterRect(Canvas*, Coord x, Coord y, Raster*);
  85.     void Point(Canvas*, Coord x, Coord y);
  86.     void MultiPoint(Canvas*, Coord x[], Coord y[], int n);
  87.     void Line(Canvas*, Coord x1, Coord y1, Coord x2, Coord y2);
  88.     void Rect(Canvas*, Coord x1, Coord y1, Coord x2, Coord y2);
  89.     void FillRect(Canvas*, Coord x1, Coord y1, Coord x2, Coord y2);
  90.     void ClearRect(Canvas*, Coord x1, Coord y1, Coord x2, Coord y2);
  91.     void Circle(Canvas*, Coord x, Coord y, int r);
  92.     void FillCircle(Canvas*, Coord x, Coord y, int r);
  93.     void Ellipse(Canvas*, Coord x, Coord y, int r1, int r2);
  94.     void FillEllipse(Canvas*, Coord x, Coord y, int r1, int r2);
  95.     void MultiLine(Canvas*, Coord x[], Coord y[], int n);
  96.     void Polygon(Canvas*, Coord x[], Coord y[], int n);
  97.     void FillPolygon(Canvas*, Coord x[], Coord y[], int n);
  98.     void BSpline(Canvas*, Coord x[], Coord y[], int n);
  99.     void ClosedBSpline(Canvas*, Coord x[], Coord y[], int n);
  100.     void FillBSpline(Canvas*, Coord x[], Coord y[], int n);
  101.     void Curve(Canvas*,
  102.     Coord x0, Coord y0, Coord x1, Coord y1,
  103.     Coord x2, Coord y2, Coord x3, Coord y3
  104.     );
  105.     void CurveTo(Canvas*,
  106.     Coord x0, Coord y0, Coord x1, Coord y1, Coord x2, Coord y2
  107.     );
  108.     void Copy(
  109.     Canvas* src, Coord x1, Coord y1, Coord x2, Coord y2,
  110.     Canvas* dst, Coord x0, Coord y0
  111.     );
  112.     void Read(Canvas*, void*, Coord x1, Coord y1, Coord x2, Coord y2);
  113.     void Write(Canvas*, const void*, Coord x1, Coord y1, Coord x2, Coord y2);
  114.  
  115.     PainterRep* Rep();
  116. protected:
  117.     Color* foreground;
  118.     Color* background;
  119.     Pattern* pattern;
  120.     Brush* br;
  121.     Font* font;
  122.     int style;
  123.     Coord curx, cury;
  124.     int xoff, yoff;
  125.     Transformer* matrix;
  126.     Dash* dash;
  127.  
  128. #ifdef _3D
  129.     void Copy(Painter*);
  130. #endif
  131.  
  132. private:
  133.     friend class Rubberband;
  134.  
  135.     PainterRep* rep;
  136.  
  137.     void Init();
  138. #ifndef _3D
  139.     void Copy(Painter*);
  140. #endif
  141.     void Begin_xor();
  142.     void End_xor();
  143.     void Map(Canvas*, Coord x, Coord y, Coord& mx, Coord& my);
  144.     void Map(Canvas*, Coord x, Coord y, short& sx, short& sy);
  145.     void MapList(Canvas*, Coord x[], Coord y[], int n, Coord mx[], Coord my[]);
  146.     void MapList(Canvas*, float x[], float y[], int n, Coord mx[], Coord my[]);
  147.     void MultiLineNoMap(Canvas* c, Coord x[], Coord y[], int n);
  148.     void FillPolygonNoMap(Canvas* c, Coord x[], Coord y[], int n);
  149. };
  150.  
  151. inline PainterRep* Painter::Rep () { return rep; }
  152.  
  153. #ifdef _3D
  154. class Painter3D : public Painter {
  155. public:
  156.     Painter3D();
  157.     Painter3D(Painter* p);
  158.     ~Painter3D();
  159.  
  160.     void CopyState(Painter* p);
  161.     void SetColors3D();
  162.     void SetColors3D(Color* f1, Color* f2, Color* f3, Color* f4);
  163.     void UseColor3D(char index);
  164.     void InvertColors();
  165.     void Border(Canvas* c, Coord x1, Coord y1, Coord x2, Coord y2,
  166.                 char inout = true, char width = 2, char flag = 15);
  167.     void Border(Canvas* c, char inout = true, char width = 2, char flag = 15);
  168. protected:
  169.     Color* fg[4];
  170. };
  171. #endif
  172.  
  173. #endif
  174.